<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户列表</title>
<%@include file="../../common/tagInclude.jsp" %>
<%@include file="../../common/headerInclude.jsp" %>
<script type="text/javascript">
	$(function() {
		$("#jvForm").validate();
	});
	function edit(userId){
		window.location = '${basePath}super/user/user-show.do?userId='+userId;
	}
	function del(userId){
		if(!confirm("确定要删除用户信息?")){
			return ;
		}
		window.location = '${basePath}super/user/user-del.do?userId='+userId;
	}
	function reset(userId){
		if(!confirm("确定要重置用户密码?")){
			return ;
		}
		window.location = '${basePath}super/user/user-reset.do?userId=' + userId;
	}
	function delSel(itemName){
		var all_checkbox = document.getElementsByName(itemName);
		var len = all_checkbox.length;
		if(isChecked(itemName) == false ){
			alert('至少选择一项');
		}else{
			if(!confirm('确认要删除指定用户?'))return;
			var values = "";
			for(var i=0;i<len ;i++){
				if(all_checkbox[i].checked)
					values += "," + all_checkbox[i].value;
			}
			if(values.length > 1)
				values = values.substring(1);
			window.location = '${basePath}super/user/user-del.do?userId='+values;
		}
	}
</script>
</head>
<body>
<div class="body-box">
	<div class="rhead">
		<div class="rpos">当前位置: 首页  - 用户 - 用户管理</div>
		<form class="ropt" method="get">
			<input type="submit" value="添加" onclick="this.form.action='${basePath}super/user/user-show.do?roleId=${roleId}';">
		</form>
		<div class="clear"></div>
	</div>
	<form action="${basePath}super/user/user-list.do" method="post" style="padding-top:5px;">
		<div>
			所属角色&nbsp;<select name="roleId" id="roleId">
					<option value="">请选择</option>
					<c:forEach items="${roleList}" var="role">
						<option value="${role.roleId}"  <c:if test="${roleId == role.roleId}">selected</c:if>>${role.roleName}</option>
					</c:forEach>				
				</select>&nbsp;&nbsp;
			<input type="submit" value="查询"><br/><br/>
			<a href="javascript:checkAll('userId',true);">全选</a>&nbsp;&nbsp;<a href="javascript:checkAll('userId',false);">取消</a>&nbsp;&nbsp;
			<a href="javascript:delSel('userId');">删除所选</a>&nbsp;&nbsp;
		</div>
		<table class="pn-ltable" width="100%" cellspacing="1" cellpadding="0" border="0">
			<thead class="pn-lthead">
			<tr>
				<th>序列</th>
				<th>用户名</th>
				<th>姓名</th>
				<th>固定电话</th>
				<th>移动电话</th>
				<th>电子邮箱</th>
				<th>部门</th>
				<th>用户角色</th>
				<th>重置密码</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody class="pn-ltbody">
			<c:forEach items="${userList}" var="user" varStatus="status">
			<tr>
				<td align="center"><input type="checkbox" name="userId" id="userId" value="${user.id}"/></td>
				<td align="center">${user.username}</td>
				<td align="center">${user.realName}</td>
				<td align="center">${user.telphone}</td>
				<td align=center>${user.mobilephone}</td>
				<td align=center>${user.email}</td>
				<td align=center>${user.deptName}</td>
				<td align=center>${user.roleInfo.roleName}</td>
				<td align=center><a href="javascript:reset('${user.id}')">重置密码</a></td>
				<td align=center><a href="javascript:edit('${user.id}');">编辑</a>&nbsp;&nbsp;<a href="javascript:del('${user.id}');">删除</a>&nbsp;&nbsp;</td>
			</tr>
			</c:forEach>
			</tbody>
		</table>
		<c:set var="pageURL" value="${basePath}super/user/user-list.do?roleId=${roleId}&"/>
		<%@include file="../../common/pages.jsp"%>
	</form>
</div>
</body>
</html>